<?php
class VB_Blockcontents extends VB_Db_Table {
	protected $_name = 'vb_blockcontents';
	protected $_primary = 'blockcontent_id';

	protected $_rowClass = 'VB_Blockcontent';
	
	protected $_referenceMap = array(
		'Page' => array(
			'columns' => 'page_id',
			'refTableClass' => 'VB_Pages',
			'refColumns' => 'page_id',
		),
		'Block' => array(
			'columns' => 'layoutblock_id',
			'refTableClass' => 'VB_Layoutblocks',
			'refColumns' => 'layoutblock_id',
		)
	);
	
	
	public function findByPageAndBlock($page_id, $block_id) {
		$query = $this->select();
		$query	->where('page_id = ?', $page_id);
		$query	->where('layoutblock_id = ?', $block_id);
		$query	->order('blockcontent_position_inblock');
		return $this->fetchAll($query);
	}
	
}
new VB_Blockcontent();